// Learn TypeScript:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html


import { Publish } from "../../meshTools/tools/Publish";
import InfoItemController from "../pfb/InfoItemController";
import InfoItemOneController from "../pfb/InfoItemOneController";
import { Config } from "../util/Config";
import { Tools } from "../util/Tools";

const { ccclass, property } = cc._decorator;


//游戏道具介绍页面
@ccclass
export default class InfoDialogController extends cc.Component {

    @property(cc.Node)
    boardBg: cc.Node = null
    @property(cc.Node)
    boardBtnClose: cc.Node = null
    @property(cc.Node)
    contentLay: cc.Node = null
   
    @property(cc.Label)
    versoion: cc.Label = null //版本号

    titleList: string[] = []//title 的列表
    tipsList: string[] = []
    generationMethodList: string[] = []
    permanentList: string[] = []
    randomList: string[] = []
    chainsList: string[] = []
    iceList: string[] = []
    scoringDetails: string[] = []

    infoImageList: cc.Prefab[] = []


    backCallback: Function = null //隐藏弹窗的回调

    onLoad() {


      



    }

    start() {
        this.versoion.string = `V ${Publish.GetInstance().getVersion()}`;
        Tools.imageButtonClick(this.boardBtnClose, Config.buttonRes + 'board_btn_close_normal', Config.buttonRes + 'board_btn_close_pressed', () => {
            this.hide()
        });

        this.contentLay.removeAllChildren()

       
    }

    show(backCallback: Function) {
        this.backCallback = backCallback
        this.node.active = true
        this.boardBg.scale = 0
        // 执行缩放动画
        cc.tween(this.boardBg)
            .to(Config.dialogScaleTime, { scale: 1 })
            .start();
    }
    hide() {
        if (this.backCallback) {
            this.backCallback()
        }
        // 执行缩放动画
        cc.tween(this.boardBg)
            .to(Config.dialogScaleTime, { scale: 0 })
            .call(() => {
                this.node.active = false
            })
            .start();
    }

    // update (dt) {}
}
